//
// Created by Martin on 2022/10/1.
//

#include <boost/static_assert.hpp>
#include <boost/mpl/transform.hpp>
#include <boost/mpl/vector_c.hpp>
#include <boost/mpl/equal.hpp>
#include <boost/mpl/placeholders.hpp>
#include <iostream>
using namespace std;
using namespace boost;

#if 0
// 自定义元函数类
struct plus_f
{
    template<class T1, class T2>
    struct apply // 嵌套元函数apply
    {
        typedef typename mpl::plus<T1, T2>::type type;
    };
};
#else
struct plus_f
{
    template<class T1, class T2>
    struct apply // 元函数转发
            : mpl::plus<T1, T2>
    {};
};
#endif

static void test_BOOST_STATICASSERT()
{
    using mpl::placeholders::_1;
    using mpl::placeholders::_2;

    BOOST_STATIC_ASSERT((
            mpl::equal<
                    mpl::vector_c<int, 2, 3, 4>,
                    mpl::transform<
                            mpl::vector_c<int, 1, 2, 3>,
                            mpl::vector_c<int, 1, 1, 1>,
                            plus_f
                    >::type
            >::type::value
    ));

    BOOST_STATIC_ASSERT((
            mpl::equal<
                    mpl::vector_c<int, 2, 3, 4>,
                    mpl::transform<
                            mpl::vector_c<int, 1, 2, 3>,
                            mpl::vector_c<int, 1, 1, 1>,
                            mpl::plus<_1, _2>
                    >::type
            >::type::value
    ));

    BOOST_STATIC_ASSERT((
            mpl::equal<
                    mpl::vector_c<int, 2, 4, 9>,
                    mpl::transform<
                            mpl::vector_c<int, 1, 2, 3>,
                            mpl::vector_c<int, 1, 2, 6>,
                            plus_f
                    >::type
            >::type::value
    ));
    BOOST_STATIC_ASSERT((
            mpl::equal<
                    mpl::vector_c<int, 2, 4, 9>,
                    mpl::transform<
                            mpl::vector_c<int, 1, 2, 3>,
                            mpl::vector_c<int, 1, 2, 6>,
                            mpl::plus<_1, _2>
                    >::type
            >::type::value
    ));

    cout << "valid OK" << endl;
}


int main()
{
    test_BOOST_STATICASSERT();
    return 0;
}
